<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderRefundsTable extends Migration
{
    public function up()
    {
        Schema::create('order_refunds', function (Blueprint $table) {
            $table->id();
	        $table->unsignedBigInteger('user_id')->index()->default(0);
	        $table->unsignedBigInteger('order_id')->index()->default(0);
	        $table->unsignedBigInteger('order_item_id')->index()->default(0);
	        $table->decimal('refund_money', 10, 2)->default(0);
	        $table->string('type')->nullable();
	        $table->string('reason')->nullable();
	        $table->string('parcel_status')->nullable();
	        $table->text('proof_images')->nullable();
	        $table->string('refund_number', 30)->nullable()->unique();
	        $table->string('refund_status')->default('pending')->index();
	        $table->text('refund_failed_reason')->nullable();
	        $table->boolean('is_order_cancel')->default(false);
	        $table->boolean('is_parcel_return')->default(false);
	        $table->boolean('should_brokerage_return')->default(true);
            $table->timestamps();
	        $table->index(['created_at']);
        });
    }

    public function down()
    {
        Schema::dropIfExists('order_refunds');
    }
}
